package day20;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * 题目：公共字串计算
 * 题目链接：https://www.nowcoder.com/practice/98dc82c094e043ccb7e0570e5342dd1b?tpId=37&&tqId=21298&rp=1&ru=/activity/oj&qru=/ta/huawei/question-ranking
 * dp[i][j] x(i),y(j)结尾的最大子串长度
 */
public class Main2 {
    public static int getMaxLen(String str1,String str2) {
        int n = str1.length();
        int m = str2.length();
        int[][] dp = new int[n+1][m+1];
        int ret = Integer.MIN_VALUE;
        for (int i = 1; i <= n ; i++) {
            for (int j = 1; j <= m ; j++) {
                if(str1.charAt(i-1) == str2.charAt(j-1)) {
                    dp[i][j] = dp[i-1][j-1] + 1;
                }
                ret = Math.max(ret,dp[i][j]);
            }
        }
        return ret;
    }
    public static void main(String[] args) throws Exception
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String str1;
        String str2;
        while((str1 = reader.readLine()) != null)
        {
            str2 = reader.readLine();
            System.out.println(getMaxLen(str1, str2));
        }
    }
}
